feat(ai): add agent/structured-call forced-tool LLM call primitive - #28
Merged
Conversation
Single Messages round-trip with tool_choice pinned to one tool, over native fetch (no SDK, no retry), generalized from alloomi's digital-employee planner. Ships the wire-tolerance helpers extractToolUseInput / findShapedObject / extractBalancedJsonObject as standalone exports, registered under the `@melandlabs/ai/agent/structured-call` subpath plus the root barrel. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
agent/structured-callsubpath to@melandlabs/ai:executeStructuredCall, a single forced-tool LLM call primitive speaking the Anthropic Messages wire format over native fetch (no SDK, no retry), generalized from alloomi's digital-employee plannerextractToolUseInput(text-embedded JSON fallback, multi-tool_use tolerance),findShapedObject(parameterizedfindPlanShape),extractBalancedJsonObject(brace-balanced scan that ignores braces inside string literals)./agent/structured-call+/index), and the root barrel (NOT in the agent barrel, per the NOTE insrc/agent/index.ts).DS_StoreTest plan
pnpm test— 99 tests pass, incl. 18 client cases (success tool_use with URL/headers/body assertions, text JSON fallback, multi-tool_use first+warn, name mismatch, no_tool_use, 402/500 http_error, network/timeout/aborted classification, decode_error, provider/thinking toggles, headers override, fetchImpl injection)pnpm tsc/pnpm -r build— all packages greenpnpm format/pnpm lint:fix— cleannode --input-type=moduleagainstdist/agent/structured-call/index.js(fakefetchImpl, assertedok:true, source:"tool_use"and body fields)🤖 Generated with Claude Code